import QtQuick 2.0
import QtQuick.Controls 2.12


Button {
    id: root
    property color _backgroundColor //矩形背景颜色
    property color _borderColor     // 边框颜色
    property color _fontColor      // 字体颜色
    property bool _small : false
    height:      contentItem.implicitHeight  + XScreenTool.base * 2//2
    width:       contentItem.implicitWidth  + XScreenTool.base * 3//6

    contentItem: XLabel {
        id: textControl
        anchors.centerIn:   parent
        text: root.text
        opacity: enabled ? 1.0 : 0.3
        color: _fontColor
        horizontalAlignment: Text.AlignHCenter
        verticalAlignment: Text.AlignVCenter
        elide: Text.ElideRight
        small:  _small
    }

//    contentItem: Item {
//        anchors.fill: parent

//        STGCLabel {
//            id: textControl
//            anchors.centerIn: parent
//            text: root.text
//            opacity: enabled ? 1.0 : 0.3
//            color: _fontColor
//            horizontalAlignment: Text.AlignHCenter
//            verticalAlignment: Text.AlignVCenter
//            elide: Text.ElideRight
//        }
//    }

    background: Rectangle   {
        id:                 buttonBkRect
        radius:             6
        color:              _backgroundColor
        anchors.fill:       parent
        opacity:            0.8
        border.color:       _borderColor
        border.width:       2
    }

    state:                                  "Default"
    states: [
        State {
            name:                       "Default"
            PropertyChanges {
                target: root;
                _borderColor:                  pressed ?   "#3E4F59" :  "#678F74"//"#449698"
                _backgroundColor:             pressed ?   "#3E4F59":  "#678F74"// "#449698")  //sgButton
                _fontColor:                   (pressed ?   "white":   "white")  //sgButton
            }
        }
    ]
}
